//
//  MultiplepicExampleViewController.m
//  SDKSample
//
//  Created by 小肥羊 on 15/8/11.
//  Copyright (c) 2015年 Zhu‘s Game House. All rights reserved.
//

#import "MultiplepicExampleViewController.h"

@interface MultiplepicExampleViewController ()

@end

@implementation MultiplepicExampleViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}






#pragma mark - 打开相册
- (IBAction)openPhotoAlbum:(UIButton *)sender {
    ZYQAssetPickerController *picker = [[ZYQAssetPickerController alloc] init];
    picker.maximumNumberOfSelection = 9;
    picker.assetsFilter = [ALAssetsFilter allPhotos];
    picker.showEmptyGroups=NO;
    picker.delegate = self;
    picker.selectionFilter = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
        if ([[(ALAsset*)evaluatedObject valueForProperty:ALAssetPropertyType] isEqual:ALAssetTypeVideo]) {
            NSTimeInterval duration = [[(ALAsset*)evaluatedObject valueForProperty:ALAssetPropertyDuration] doubleValue];
            return duration >= 5;
        } else {
            return YES;
        }
    }];
    [self presentViewController:picker animated:YES completion:nil];
}


#pragma mark - ZYQAssetPickerController Delegate
-(void)assetPickerController:(ZYQAssetPickerController *)picker didFinishPickingAssets:(NSArray *)assets
{
    for (int i=0; i<assets.count; i++) {
        ALAsset *asset=assets[i];
        NSLog(@"%@",asset.defaultRepresentation.url.absoluteString);
    }
//    [src.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
//    
//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//        src.contentSize=CGSizeMake(assets.count*src.frame.size.width, src.frame.size.height);
//        dispatch_async(dispatch_get_main_queue(), ^{
//            pageControl.numberOfPages=assets.count;
//        });
//        
//        for (int i=0; i<assets.count; i++) {
//            ALAsset *asset=assets[i];
//            UIImageView *imgview=[[UIImageView alloc] initWithFrame:CGRectMake(i*src.frame.size.width, 0, src.frame.size.width, src.frame.size.height)];
//            imgview.contentMode=UIViewContentModeScaleAspectFill;
//            imgview.clipsToBounds=YES;
//            UIImage *tempImg=[UIImage imageWithCGImage:asset.defaultRepresentation.fullScreenImage];
//            dispatch_async(dispatch_get_main_queue(), ^{
//                [imgview setImage:tempImg];
//                [src addSubview:imgview];
//            });
//        }
//    });
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
